<include file='public/_meta'>
<title>车辆列表</title>
<body>

<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 车辆档案 <span class="c-gray en">&gt;</span> 车辆列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
            <div class="text-c" id="search_down"> 添加日期：
                <input type="text" onfocus="WdatePicker({ maxDate:'#F{ $dp.$D(\'datemax\')||\'%y-%M-%d\' }' })" id="datemin" class="input-text Wdate" style="width:100px;">
                -
                <input type="text" onfocus="WdatePicker({ minDate:'#F{ $dp.$D(\'datemin\') }',maxDate:'%y-%M-%d' })" id="datemax" class="input-text Wdate" style="width:100px;">
                <input type="text" class="input-text" style="width:250px" placeholder="车牌、车架、卡号、智能设备号..." id="search_inpute" >
                <span class="select-box" style="width:96px;">
                    <select class="select" name="supplier_no" id="supplier_no" size="1">
                        <option value="" style="color: #429842;">车机型号</option>
                        <option value="1376920001">W</option>
                         <option value="1376920003">S-IOT</option>
                        <option value="1376920002">S</option>
                    </select>
                </span>
                <span class="select-box" style="width:96px;">
                    <select class="select" name="sim_card" id="sim_card" size="1">
                        <option value="" style="color: #429842;">SIM卡商</option>
                        <option value="1376920004">阿里云</option>
                        <option value="1376920005">赛卡</option>
                    </select>
                </span>
                <button type="submit" class="btn btn-success radius" id="search_btn"><i class="Hui-iconfont">&#xe665;</i> 搜索</button>       
            </div>
    <div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l"> <a class="btn btn-primary radius" onclick="product_send('阿里云短信通道','{:url('index/message/send')}','',350)" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 阿里云短信通道</a></span> <span class="ml-5"> <a class="btn btn-success radius" onclick="dispach('赛卡短信通道','{:url('index/message/dispach')}','',350)" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 赛卡短信通道</a></span><span class="r">共有数据：<strong>{$number}</strong> 条</span> </div>
    <div class="mt-20">
        <table class="table table-border table-bordered table-bg table-hover table-sort">
            <thead>
                <tr class="text-c">
                
                    <th width="40">ID</th>
                    <th width="">车牌号</th>
                    <th width="">车架号</th>
                    <th width="120">卡号</th>
                    <th width="150">卡序列号</th>
                    <th width="150">智能设备号</th>                    
                    <th>车机厂商</th>
                    <th>SIM卡商</th>
                    <th width="40">状态</th>
                    <th width="120">车机时间</th>
                    <th width="">添加时间</th>
                    <th width="100">操作</th>
                </tr>
            </thead>
            <tbody>
                
            </tbody>
        </table>
    </div>
</div>
<!--_footer 作为公共模版分离出去-->
<include file='public/_footer'>
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__PUBLIC__/lib/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/lib/My97DatePicker/4.8/WdatePicker.js"></script> 
<script type="text/javascript" src="__PUBLIC__/lib/datatables/1.10.0/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="__PUBLIC__/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="__PUBLIC__/static/h-ui/js/H-ui.js"></script>
<!-- <script type="text/javascript" src="__PUBLIC__/lib/jquery/1.9.1/jquery.js"></script> -->
<script type="text/javascript">
$(function(){
    var table = $('.table-sort').DataTable({
        "aaSorting": [[ 0, "desc" ]],//默认第几个排序
        // "bStateSave": true,//状态保存
         searching: false,
        "aoColumnDefs": [
          //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
          {"orderable":false,"aTargets":[0,1,2,3,4,5,6,7,8,9,10,11]}// 制定列不参与排序
        ],
        "bProcessing" : true, //开启读取服务器数据时显示正在加载中……特别是大数据量的时候，开启此功能比较好  
        "bServerSide" : true,//服务器处理分页，默认是false，需要服务器处理，必须true  
        "ajax": {
            "url": "{:url('index/message/index')}",
            "type": "POST"
        },
        displayLength: 10,
        columns: [
        { data: 'car_id' },
        { data: 'car_sn'},
        { data: 'car_unique_id' },
        { data: 'cardcode'},
        { data: 'sim_id'},
        { data: 'equipment_id'},
        { data:'supplier_no',render:data=>{
                switch (data) {
                    case '1376920002':
                    data = '赛卡(博鹭途)';     
                        break;
                    case '1376920001':
                    data = '唯特迅';     
                        break;
                        case '1376920003':
                    data = '赛卡(IOT)';     
                        break;
                    default:
                    data = '未知';   
                        break;
                }
               
                return data;
            } 
        },
        { data:'sim_card',render:data=>{
                switch (data) {
                    case '1376920004':
                    data = '阿里云';     
                        break;
                    case '1376920005':
                    data = '赛卡';     
                        break;
                    default:
                    data = '未知';   
                        break;
                }
               
                return data;
            } 
        },
        { render:function (data, type, row, meta) {

                if(row.cars_info){
                    if(row.cars_info.network_status == 0){
                        return '<span class="label radius">离线</span>';
                    }else if(row.cars_info.network_status == 1){
                        return '<span class="label label-success radius">在线</span>';
                    }else{
                        return '未知';
                    }
                    
                }else{
                    return '未知';
                }
                
            } 
        },
        { render:function (data, type, row, meta) {
                if(row.cars_info){
                    if(row.cars_info.machine_report_time!=null && row.cars_info.machine_report_time!=0){
                        let formatTimeS = new Date(row.cars_info.machine_report_time);
                        let _year = formatTimeS.getFullYear()
                        let _month = formatTimeS.getMonth()+1;
                        let _date = formatTimeS.getDate();
                        let _hour = formatTimeS.getHours();
                        let _minute = formatTimeS.getMinutes();
                        let _second = formatTimeS.getSeconds();
                        return _year+'-'+_month+'-'+_date+' '+_hour+':'+_minute+':'+_second;
                        
                    }else{
                       data = '未知'; 
                    }
                }else{
                    data = '未知';
                }
                return data;
            } 
        },
        { data: 'create_time' },
        { className: "td-manage",data: '',render: function (data, type, row, meta) {
                                var str = ''; 
                                if(row.cardcode!=='' && row.sim_id!==''){
                                    if(row['sim_card'] == 1376920004){
                                        
                                        str += '<a title="车辆控制" href="javascript:;" onclick="operate(';
                                        str += "'车辆控制',";
                                        str += "'{:url('index/message/operate')}?cardcode="+row['cardcode']+"'";
                                        str += ",'',450)\"";
                                        str += 'class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe61d;</i></a>';

                                        str += '<a title="查询卡状态" href="javascript:;" onclick="details(';
                                        str += "'查询卡状态',";
                                        str += "'{:url('index/message/details')}?sim_id="+row['sim_id']+"'";
                                        str += ",'',300)\"";
                                        str += 'class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe627;</i></a>';

                                        str += '<a title="流量查询" href="javascript:;" onclick="traffic(';
                                        str += "'流量查询',";
                                        str += "'{:url('index/message/traffic')}?sim_id="+row['sim_id']+"'";
                                        str += ",'',300)\"";
                                        str += 'class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe61c;</i></a>';

                                        str += '<a title="套餐列表查询" href="javascript:;" onclick="traffic(';
                                        str += "'套餐列表查询',";
                                        str += "'{:url('index/message/package')}?sim_id="+row['sim_id']+"'";
                                        str += ",'900',600)\"";
                                        str += 'class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6f3;</i></a>';

                                        if(row['supplier_no'] == 1376920002 || row['supplier_no'] == 1376920003){
                                            str += '<a title="升级IOT" href="javascript:;" onclick="exchange(this,'+row['car_id']+')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe679;</i></a>';
                                        }
                                        
                                                
                                    }else if(row['sim_card'] == 1376920005){
                                        
                                        str += '<a title="车辆控制" href="javascript:;" onclick="command(';
                                        str += "'车辆控制',";
                                        str += "'{:url('index/message/command')}?cardcode="+row['cardcode']+"'";
                                        str += ",'',450)\"";
                                        str += 'class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe61d;</i></a>';

                                        str += '<a title="查询卡状态" href="javascript:;" onclick="realTime(';
                                        str += "'查询卡状态',";
                                        str += "'{:url('index/message/realTime')}?cardcode="+row['sim_id']+"'";
                                        str += ",'',250)\"";
                                        str += 'class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe627;</i></a>';

                                        str += '<a title="流量查询" href="javascript:;" onclick="flow(';
                                        str += "'流量查询',";
                                        str += "'{:url('index/message/flow')}?cardcode="+row['cardcode']+"'";
                                        str += ",'',250)\"";
                                        str += 'class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe61c;</i></a>';

                                        str += '<a title="套餐列表查询" href="javascript:;" onclick="information(';
                                        str += "'套餐列表查询',";
                                        str += "'{:url('index/message/information')}?cardcode="+row['cardcode']+"'";
                                        str += ",'',350)\"";
                                        str += 'class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6f3;</i></a>';

                                        if(row['supplier_no'] == 1376920002 || row['supplier_no'] == 1376920003){
                                            str += '<a title="升级IOT" href="javascript:;" onclick="exchange(this,'+row['car_id']+')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe679;</i></a>';
                                        }
                                    }

                                    
                                }
                                return str;
                                
                            }
        
        },

        ],
         
    });

    $("#search_btn").click(res=>{
        request();
    });

    $("#search_down").keydown(event=>{
           if (event.which == 13){
                request();
           }
    })

    function request() {
        table.settings()[0].ajax.data = {
            'datemin':$('#datemin').val(),
            'datemax':$('#datemax').val(),
            'supplier_no':$('#supplier_no').val(),
            'sim_card':$('#sim_card').val(),
            'search_inpute':$('#search_inpute').val()
        };
        table.ajax.reload();
    }

});
function product_send(title,url,w,h){
	layer_show(title,url,w,h);
}

function dispach(title,url,w,h){
    layer_show(title,url,w,h);
}

function operate(title,url,w,h) {
    layer_show(title,url,w,h);
}
function details(title,url,w,h) {
    layer_show(title,url,w,h);
}
function traffic(title,url,w,h) {
    layer_show(title,url,w,h);
}

function command(title,url,w,h){
    layer_show(title,url,w,h);
}

function information(title,url,w,h){
    layer_show(title,url,w,h);
}

function realTime(title,url,w,h){
    layer_show(title,url,w,h);
}

function flow(title,url,w,h){
    layer_show(title,url,w,h);
}

function exchange(obj,car_id){
    layer.confirm('确认要升级IOT吗?',function(index){
        $.ajax({
            type: 'POST',
            url: '{:url('index/message/exchange')}',
            data:{'car_id':car_id},
            dataType: 'json',
            success: function(data){
                if(data.code == 0){
                   layer.msg('切换成功!',{icon: 6,time:1000});
                }else{
                    layer.msg(data['msg']);
                }
            },
            error:function(data) {
                console.log(data.msg);
            },
        }); 
        
        
    });
}

</script>
</body>
</html>